package view;

import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.Rectangle;
import java.awt.Dimension;
import javax.swing.JList;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.SwingConstants;
import model.*;
import java.util.*;
import javax.swing.JComboBox;
import javax.swing.ListSelectionModel;


public class frmModLectura extends JFrame {
	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private JLabel lblAtributo = null;
	private JList listAtributo = null;
	private JLabel lblLectura = null;
	private JLabel lblTitulo = null;
	private JLabel lblDato = null;
	private JTextField txtDato = null;
	private JButton btnModificar = null;
	private JButton btnAsignar = null;
	private JButton btnAceptar = null;
	private JButton btnCanecelar = null;
	private JList listInvestigacion = null;
	private JLabel lblInvestigacion = null;
	private Fachada jebi = null;
	private JComboBox cmbTipo = null;

	/**
	 * This is the default constructor
	 */
	public frmModLectura() {
		super();
		initialize();
	//	this.jebi = new Fachada();
		this.btnCanecelar.addActionListener(new java.awt.event.ActionListener(){
			public void actionPerformed(java.awt.event.ActionEvent evt) {
	              btnCancelarActionPerformed(evt);
	            }
		});
		}
	
	public frmModLectura(Fachada jebi){
		super();
		initialize();
		this.jebi = jebi;
				
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(643, 301);
		this.setContentPane(getJContentPane());
		this.setTitle("JFrame");
		this.setLblTitulo(" ");
		//cargoListaAtributo();  descomentar para ver la carga de datos
		//cargoListaInvestigacion();
		//cargoComboTipo(); // esto no va porque el tipo se carga en metadata
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			lblInvestigacion = new JLabel();
			lblInvestigacion.setBounds(new Rectangle(533, 19, 91, 19));
			lblInvestigacion.setHorizontalAlignment(SwingConstants.RIGHT);
			lblInvestigacion.setText("Investigacion");
			lblDato = new JLabel();
			lblDato.setBounds(new Rectangle(211, 46, 59, 15));
			lblDato.setText("Datos");
			lblTitulo = new JLabel();
			lblTitulo.setBounds(new Rectangle(209, 17, 247, 16));
			lblTitulo.setText("");
			lblLectura = new JLabel();
			lblLectura.setBounds(new Rectangle(149, 16, 61, 17));
			lblLectura.setText("Lectura");
			lblAtributo = new JLabel();
			lblAtributo.setBounds(new Rectangle(14, 14, 63, 21));
			lblAtributo.setText("Atributo");
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(lblAtributo, null);
			jContentPane.add(getListAtributo(), null);
			jContentPane.add(lblLectura, null);
			jContentPane.add(lblTitulo, null);
			jContentPane.add(lblDato, null);
			jContentPane.add(getTxtDato(), null);
			jContentPane.add(getBtnModificar(), null);
			jContentPane.add(getBtnAsignar(), null);
			jContentPane.add(getBtnAceptar(), null);
			jContentPane.add(getBtnCanecelar(), null);
			jContentPane.add(getListInvestigacion(), null);
			jContentPane.add(lblInvestigacion, null);
			jContentPane.add(getCmbTipo(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes listAtributo	
	 * 	
	 * @return javax.swing.JList	
	 */
	private JList getListAtributo() {
		if (listAtributo == null) {
			listAtributo = new JList();
			listAtributo.setBounds(new Rectangle(16, 46, 183, 165));
			listAtributo.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		}
		return listAtributo;
	}

	/**
	 * This method initializes txtDato	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getTxtDato() {
		if (txtDato == null) {
			txtDato = new JTextField();
			txtDato.setBounds(new Rectangle(209, 67, 163, 19));
		}
		return txtDato;
	}

	/**
	 * This method initializes btnModificar	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getBtnModificar() {
		if (btnModificar == null) {
			btnModificar = new JButton();
			btnModificar.setBounds(new Rectangle(240, 120, 156, 21));
			btnModificar.setText("Modificar");
		}
		return btnModificar;
	}

	/**
	 * This method initializes btnAsignar	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getBtnAsignar() {
		if (btnAsignar == null) {
			btnAsignar = new JButton();
			btnAsignar.setBounds(new Rectangle(239, 179, 157, 21));
			btnAsignar.setText("> > > >");
		}
		return btnAsignar;
	}

	/**
	 * This method initializes btnAceptar	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getBtnAceptar() {
		if (btnAceptar == null) {
			btnAceptar = new JButton();
			btnAceptar.setBounds(new Rectangle(219, 233, 93, 23));
			btnAceptar.setText("Aceptar");
		}
		return btnAceptar;
	}

	/**
	 * This method initializes btnCanecelar	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getBtnCanecelar() {
		if (btnCanecelar == null) {
			btnCanecelar = new JButton();
			btnCanecelar.setBounds(new Rectangle(336, 234, 90, 23));
			btnCanecelar.setText("Salir");
		}
		return btnCanecelar;
	}

	/**
	 * This method initializes listInvestigacion	
	 * 	
	 * @return javax.swing.JList	
	 */
	private JList getListInvestigacion() {
		if (listInvestigacion == null) {
			listInvestigacion = new JList();
			listInvestigacion.setBounds(new Rectangle(444, 47, 180, 192));
			listInvestigacion.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		}
		return listInvestigacion;
	}
	private void setLblTitulo(String arg){
		this.lblTitulo.setText("titulo de la lectura");
	}
	
	private void cargoListaAtributo(){
		this.listAtributo.setListData(this.jebi.getColAtributo(this.jebi.getFicha()).toArray());
	}
	
	private void cargoListaInvestigacion(){
		this.listInvestigacion.setListData(this.jebi.getcolInvestigacion().toArray());	
	}

	private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt){
		this.dispose();
	}

	/**
	 * This method initializes cmbTipo	
	 * 	
	 * @return javax.swing.JComboBox	
	 */
	private JComboBox getCmbTipo() {
		if (cmbTipo == null) {
			cmbTipo = new JComboBox();
			cmbTipo.setBounds(new Rectangle(17, 225, 180, 21));
		}
		return cmbTipo;
	}
	
	
	
	
	
}  //  @jve:decl-index=0:visual-constraint="10,10"
